package com.deep.stream.consumer.controller;

import com.deep.stream.server.dao.UserInfo;
import org.springframework.context.annotation.Bean;
import org.springframework.stereotype.Controller;

import java.util.function.Consumer;

/**
 * @author deeprado
 * @date 2021/9/7 15:30
 */
@Controller
public class FunctionInputController {

    @Bean
    public Consumer<String> autoReceive() {
        return message -> {
            System.out.println(message);
        };
    }

    @Bean
    public Consumer<UserInfo> userReceive() {
        return userInfo -> {
            System.out.println("username = " + userInfo.getUsername() + " age = " + userInfo.getAge());
        };
    }

    @Bean
    public Consumer<UserInfo> kafkaReceive() {
        return userInfo -> {
            System.out.println(userInfo.getUsername() + "=>" + userInfo.getAge());
        };
    }

    @Bean
    public Consumer<UserInfo> kafkaReceive2() {
        return userInfo -> {
            System.out.println(userInfo.getUsername() + "=>" + userInfo.getAge() + "(2)");
        };
    }
}
